<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="学生名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入学生名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="性别" prop="sex">
        <el-select v-model="queryParams.sex" placeholder="请选择性别" clearable>
          <el-option
            v-for="dict in dict.type.sys_user_sex"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="年龄" prop="age">
        <el-input
          v-model="queryParams.age"
          placeholder="请输入年龄"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学历" prop="educationBackground">
        <el-input
          v-model="queryParams.educationBackground"
          placeholder="请输入学历"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="班级" prop="grade">
        <el-select v-model="queryParams.grade" placeholder="请选择班级" clearable>
          <el-option
            v-for="dict in dict.type.bbl_grade"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="专业" prop="major">
        <el-input
          v-model="queryParams.major"
          placeholder="请输入专业"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学校" prop="school">
        <el-input
          v-model="queryParams.school"
          placeholder="请输入学校"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机" prop="phone">
        <el-input
          v-model="queryParams.phone"
          placeholder="请输入手机"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="家长手机" prop="parentsPhone">
        <el-input
          v-model="queryParams.parentsPhone"
          placeholder="请输入家长手机"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学生状态" prop="states">
        <el-select v-model="queryParams.states" placeholder="请选择学生状态" clearable>
          <el-option
            v-for="dict in dict.type.bbl_student_state"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="校区" prop="campus">
        <el-select v-model="queryParams.campus" placeholder="请选择校区" clearable>
          <el-option
            v-for="dict in dict.type.bbl_campus"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="模拟面试" prop="interviewTest">
        <el-select v-model="queryParams.interviewTest" placeholder="请选择模拟面试" clearable>
          <el-option
            v-for="dict in dict.type.bbl_interview_test"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="结业考试" prop="finalTest">
        <el-select v-model="queryParams.finalTest" placeholder="请选择结业考试" clearable>
          <el-option
            v-for="dict in dict.type.bbl_final_test"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否重点关注" prop="attention">
        <el-select v-model="queryParams.attention" placeholder="请选择是否重点关注" clearable>
          <el-option
            v-for="dict in dict.type.bbl_attention"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['student:student:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['student:student:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="handleUpdateState"
          v-hasPermi="['student:student:state']"
        >状态修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-refresh"
          size="mini"
          :disabled="single"
          @click="handleRepeat"
          v-hasPermi="['student:student:repetition']"
        >留级转班</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-refresh"
          size="mini"
          :disabled="single"
          @click="handleAttention"
          v-hasPermi="['student:studentattentionlog:save']"
        >重点关注</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-refresh"
          size="mini"
          :disabled="single"
          @click="handleStudenttrack"
          v-hasPermi="['student:studenttracklog:saveStudenttrack']"
        >添加跟踪</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['student:student:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['student:student:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="studentList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="学生id" align="center" prop="id" />
      <el-table-column label="学生名称" align="center" prop="name" />
      <el-table-column label="性别" align="center" prop="sex">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.sex"/>
        </template>
      </el-table-column>
      <el-table-column label="年龄" align="center" prop="age" />
      <el-table-column label="学历" align="center" prop="educationBackground" />
      <el-table-column label="班级" align="center" prop="grade">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.bbl_grade" :value="scope.row.grade"/>
        </template>
      </el-table-column>
     <!-- <el-table-column label="专业" align="center" prop="major" />-->
      <!--<el-table-column label="学校" align="center" prop="school" />-->
      <!--<el-table-column label="手机" align="center" prop="phone" />-->
     <!-- <el-table-column label="家长手机" align="center" prop="parentsPhone" />-->
      <el-table-column label="学生状态" width="125" align="center" prop="states">
        <template slot-scope="scope">
          <!--<dict-tag :options="dict.type.bbl_student_state" :value="scope.row.states"/>-->
          <el-select ref="states" v-model="scope.row.states"
                     placeholder="请选择学生状态" @change="updateSingleStatus(scope.row)">
            <el-option
              v-for="dict in dict.type.bbl_student_state"
              v-bind:key="dict.label"
              :label="dict.label"
              :value="dict.value"
              v-html="
          `<span style='color:${getUrgencyColor(dict.value)}'>${
            dict.label
      }</span>`"
            ></el-option>
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="校区" align="center" prop="campus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.bbl_campus" :value="scope.row.campus"/>
        </template>
      </el-table-column>
      <el-table-column label="模拟面试" width="110" align="center" prop="interviewTest">
        <template slot-scope="scope">
         <!-- <dict-tag :options="dict.type.bbl_interview_test" :value="scope.row.interviewTest"/>-->
          <el-select ref="interviewTest" v-model="scope.row.interviewTest"
                     placeholder="请选择面试结果" @change="updateSingleStatus(scope.row)">
            <el-option
              v-for="dict in dict.type.bbl_interview_test"
              v-bind:key="dict.label"
              :label="dict.label"
              :value="dict.value"
              v-html="
          `<span style='color:${getUrgencyColor(dict.value)}'>${
            dict.label
      }</span>`"
            ></el-option>
          </el-select>
        </template>
      </el-table-column>
      <el-table-column  label="结业考试"  align="center" prop="finalTest">
        <template  slot-scope="scope">
          <!--<dict-tag :options="dict.type.bbl_final_test" :value="scope.row.finalTest"/>-->
          <el-select ref="finalTest" v-model="scope.row.finalTest"
                     placeholder="请选择面试结果" @change="updateSingleStatus(scope.row)">
            <el-option
              v-for="dict in dict.type.bbl_final_test"
              v-bind:key="dict.label"
              :label="dict.label"
              :value="dict.value"
              v-html="
          `<span style='color:${getUrgencyColor(dict.value)}'>${
            dict.label
      }</span>`"
            ></el-option>
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="是否重点关注" align="center" prop="attention">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.bbl_attention" :value="scope.row.attention"/>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['student:student:edit']"
          >修改</el-button>
         <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleRepeat(scope.row)"
            v-hasPermi="['student:student:repetition']"
          >留级转班</el-button>-->
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['student:student:remove']"
          >删除</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-set-up"
            @click="handleTrackDetails(scope.row)"
          >跟踪详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改学生对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="学生名称" prop="name">
          <el-input v-model="form.name" placeholder="请输入学生名称" />
        </el-form-item>
        <el-form-item label="性别" prop="sex">
          <el-select v-model="form.sex" placeholder="请选择性别">
            <el-option
              v-for="dict in dict.type.sys_user_sex"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="年龄" prop="age">
          <el-input v-model="form.age" placeholder="请输入年龄" />
        </el-form-item>
        <el-form-item label="学历" prop="educationBackground">
          <el-input v-model="form.educationBackground" placeholder="请输入学历" />
        </el-form-item>
        <el-form-item label="班级" prop="grade">
          <el-select v-model="form.grade" placeholder="请选择班级">
            <el-option
              v-for="dict in dict.type.bbl_grade"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="专业" prop="major">
          <el-input v-model="form.major" placeholder="请输入专业" />
        </el-form-item>
        <el-form-item label="学校" prop="school">
          <el-input v-model="form.school" placeholder="请输入学校" />
        </el-form-item>
        <el-form-item label="手机" prop="phone">
          <el-input v-model="form.phone" placeholder="请输入手机" />
        </el-form-item>
        <el-form-item label="家长手机" prop="parentsPhone">
          <el-input v-model="form.parentsPhone" placeholder="请输入家长手机" />
        </el-form-item>
        <el-form-item label="学生状态" prop="states">
          <el-select v-model="form.states" placeholder="请选择学生状态">
            <el-option
              v-for="dict in dict.type.bbl_student_state"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="校区" prop="campus">
          <el-select v-model="form.campus" placeholder="请选择校区">
            <el-option
              v-for="dict in dict.type.bbl_campus"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="模拟面试" prop="interviewTest">
          <el-select v-model="form.interviewTest" placeholder="请选择模拟面试">
            <el-option
              v-for="dict in dict.type.bbl_interview_test"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结业考试" prop="finalTest">
          <el-select v-model="form.finalTest" placeholder="请选择结业考试">
            <el-option
              v-for="dict in dict.type.bbl_final_test"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否重点关注" prop="attention">
          <el-radio-group v-model="form.attention">
            <el-radio
              v-for="dict in dict.type.bbl_attention"
              :key="dict.value"
              :label="parseInt(dict.value)"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 状态修改学生对话框 -->
    <el-dialog :title="title" :visible.sync="open2" width="500px" append-to-body>
      <el-form ref="updateForm" :model="updateForm" :rules="rules" label-width="80px">
        <el-form-item label="学生状态" prop="states">
          <el-select v-model="updateForm.states" @change="$forceUpdate()" placeholder="请选择学生状态">
            <el-option
              v-for="dict in dict.type.bbl_student_state"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="模拟面试" prop="interviewTest">
          <el-select v-model="updateForm.interviewTest" @change="$forceUpdate()"  placeholder="请选择模拟面试">
            <el-option
              v-for="dict in dict.type.bbl_interview_test"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="结业考试" prop="finalTest">
          <el-select v-model="updateForm.finalTest" @change="$forceUpdate()"  placeholder="请选择结业考试">
            <el-option
              v-for="dict in dict.type.bbl_final_test"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm2">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 留级转班对话框 -->
    <el-dialog :title="title" :visible.sync="open3" width="500px" append-to-body>
      <el-form ref="form" :model="repeatGradeForm" :rules="rules" label-width="80px">
        <el-form-item label="姓名" prop="name">
          <el-input v-model="form.name" placeholder="请输入姓名" :disabled="true"/>
        </el-form-item>
        <el-form-item label="转入班级" prop="grade" >
          <el-select v-model="repeatGradeForm.grade" placeholder="请选择转入班级">
            <el-option
              v-for="dict in dict.type.bbl_grade"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="学生状态" prop="states">
          <el-select v-model="repeatGradeForm.states" placeholder="请选择学生状态">
            <el-option
              v-for="dict in dict.type.bbl_student_state"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="remarks">
          <el-input type="textarea" v-model="repeatGradeForm.remarks" placeholder="请输入备注"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitRepeatForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 添加跟踪对话框 -->
    <el-dialog :title="title" :visible.sync="open4" width="500px" append-to-body>
      <el-form ref="form" :model="repeatTrack" :rules="rules" label-width="80px">
        <el-form-item label="学生编号" prop="stuSn">
          <el-input v-model="repeatTrack.stuSn" placeholder="请输入学生编号" />
        </el-form-item>
        <el-form-item label="问题类型" prop="problem">
          <el-select v-model="repeatTrack.problem" placeholder="请选择问题类型">
            <el-option
              v-for="dict in dict.type.bbl_problem"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="扣除分数" prop="deductMarks">
          <el-input v-model="repeatTrack.deductMarks" placeholder="请输入扣除分数" />
        </el-form-item>
        <el-form-item label="发生时间" prop="occurrenceTime">
          <el-date-picker clearable
                          v-model="repeatTrack.occurrenceTime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择发生时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="问题描述" prop="problemDescription">
          <el-input type="textarea" v-model="repeatTrack.problemDescription" placeholder="请输入问题描述" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitStudenttrack">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 跟踪详情 -->
    <el-dialog :title="title" :visible.sync="open6" width="500px" append-to-body>
      <div class="block" >
        <el-timeline v-for="details in trackDetails">
          <el-timeline-item :timestamp=details.occurrenceTime placement="top">
            <el-card>
              <h4>跟踪人【{{details.teacherName}}】</h4>
              <p>情况说明:{{details.problemDescription}}</p >
            </el-card>
          </el-timeline-item>
        </el-timeline>
      </div>
    </el-dialog>

    <!-- 添加或修改重点关注对话框 -->
    <el-dialog :title="title" :visible.sync="open5" width="500px" append-to-body>
      <el-form ref="form" :model="repeatAttention" :rules="rules" label-width="80px">
        <el-form-item label="学生名称" prop="stuName">
          <el-input v-model="repeatAttention.stuName" placeholder="请输入学生名称" :disabled="true"/>
        </el-form-item>
        <el-form-item label="负责老师" prop="teacherName">
          <el-select v-model="repeatAttention.teacherName" placeholder="请选择负责老师">
            <el-option
              v-for="dict in dict.type.bbl_teacher"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="创建时间" prop="time">
          <el-date-picker clearable
                          v-model="repeatAttention.time"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择创建时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="困难系数" prop="difficultyCoefficient">
          <el-select v-model="repeatAttention.difficultyCoefficient" placeholder="请选择困难系数">
            <el-option
              v-for="dict in dict.type.bbl_degree_difficulty"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否留级" prop="stayclass">
          <el-tooltip :content="'Switch value: ' + value" placement="top">
            <el-switch
              v-model="repeatAttention.stayclass"
              active-color="#13ce66"
              inactive-color="#ff4949"
              active-value="是"
              inactive-value="否">
            </el-switch>
          </el-tooltip>
        </el-form-item>
        <el-form-item label="备注" prop="comment">
          <el-input type="textarea" v-model="repeatAttention.comment" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitAttention">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listStudent, getStudent, delStudent, addStudent, updateStudent , updateStudentState , repeatGrade } from "@/api/student/student";
import { saveStudenttrack , getStudenttrackstuSn } from "@/api/student/studenttracklog";
import { saveStudentattentionlog } from "@/api/student/studentattentionlog";

export default {
  name: "Student",
  dicts: ['bbl_campus', 'bbl_grade', 'sys_user_sex', 'bbl_attention', 'bbl_final_test', 'bbl_student_state', 'bbl_interview_test','bbl_problem' , 'bbl_degree_difficulty'
  , 'bbl_teacher'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 学生表格数据
      studentList: [],
      // 跟踪详情
      trackDetails: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      open2:false,
      open3:false,
      open4:false,
      open5:false,
      open6:false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        sex: null,
        age: null,
        educationBackground: null,
        grade: null,
        major: null,
        school: null,
        phone: null,
        parentsPhone: null,
        states: null,
        campus: null,
        interviewTest: null,
        finalTest: null,
        attention: null
      },
      // 表单参数
      form: {},
      // 修改的表单
      updateForm: {
        ids: [],
        states: null,
        interviewTest: null,
        finalTest: null
      },
      // 留级转班表单
      repeatGradeForm: {
        id: null,
        grade: null,
        states: null,
        remarks: null
      },
      //重点关注表单
      repeatAttention: {
        id: null,
        stuName: null,
        stuSn: null,
        teacherName: null,
        comment: null,
        time: null,
        difficultyCoefficient: null,
        //是否留级
        stayclass: '是',
      },
      //添加跟踪表单
      repeatTrack: {
        id: null,
        stuSn: null,
        problem: null,
        deductMarks: null,
        occurrenceTime: null,
        problemDescription: null,
        teacherId: null,
        teacherName: null,
      },
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 获取紧急程度颜色
    getUrgencyColor(code) {
      if (code == "0") {
        const color = "orange";
        // 改变下拉框颜色值
        this.$parent.$el.children[0].children[0].style.color = '' + color + '';
        return color;
      } else if (code == "1") {
        const color = "#39b54a";
        return color;
      } else if (code == "2") {
        const color = "red";
        return color;
      } else if (code == "3") {
        const color = "#0099FF";
        return color;
      } else if (code == "4") {
        const color = "#787878";
        return color;
      }
      const color = "#787878";
      return color;
    },
    /** 查询学生列表 */
    getList() {
      this.loading = true;
      listStudent(this.queryParams).then(response => {
        this.studentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.open2 = false;
      this.open3 = false;
      this.open4 = false;
      this.open5 = false;
      this.open6 = false;
      this.reset();
    },
    //留级转班
    resetRepeat(){
      this.repeatGradeForm = {
        id: null,
        grade: null,
        states: "-3",
        remarks: null
      }
    },
    //添加跟踪
    resetTrack(){
      this.repeatTrack = {
        id: null,
        stuSn: null,
        problem: null,
        deductMarks: null,
        occurrenceTime: null,
        problemDescription: null,
        teacherId: null,
        teacherName: null,
      }
    },
    //重点关注
    resetAttention(){
      this.repeatAttention = {
        id: null,
        stuName: null,
        stuSn: null,
        teacherName: null,
        comment: null,
        time: null,
        difficultyCoefficient: null,
        //是否留级
        stayclass: '是',
      }
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        name: null,
        sex: null,
        age: null,
        educationBackground: null,
        grade: null,
        major: null,
        school: null,
        phone: null,
        parentsPhone: null,
        states: null,
        campus: null,
        interviewTest: null,
        finalTest: null,
        attention: null
      };
      this.resetForm("form");
    },
    //状态修改
    resetUpdate(){
      this.updateForm = {
        states: null,
        interviewTest: null,
        finalTest: null
      };
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /*状态修改*/
    handleUpdateState(){
      this.resetUpdate();
      this.updateForm.ids = this.ids;
      this.open2 = true;
      this.title = "选中[" + this.ids.length + "]条数据"
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加学生";
    },
    /*重点关注按钮操作*/
    handleAttention(row) {
      this.resetAttention();
      const id = row.id || this.ids;
      getStudent(id).then(res => {
       // this.repeatTrack.id = res.data.id;
        this.repeatAttention.stuName = res.data.name;
        this.repeatAttention.stuSn = res.data.id;
        this.form.name = res.data.name;
        //this.repeatGradeForm.studentStatus = res.data.studentStatus;
        this.title = this.form.name + "重点关注";
      });
      this.open5 = true;
    },
    /** 重点关注 */
    submitAttention(){
      saveStudentattentionlog(this.repeatAttention).then(res => {
        this.$modal.msgSuccess("添加关注成功");
        this.open5 = false;
        this.getList();
      })
    },
    /** 添加跟踪钮操作 */
    handleStudenttrack(row) {
      this.resetTrack();
      const id = row.id || this.ids;
      getStudent(id).then(res => {
       // this.repeatTrack.id = res.data.id;
        this.repeatTrack.stuSn = res.data.id;
        this.form.name = res.data.name;
        //this.repeatGradeForm.studentStatus = res.data.studentStatus;
        this.title = this.form.name + "跟踪添加";
      });
      this.open4 = true;
    },
    /** 添加跟踪 */
    submitStudenttrack(){
      saveStudenttrack(this.repeatTrack).then(res => {
        this.$modal.msgSuccess("信息修改成功");
        this.open4 = false;
        this.getList();
      })
    },
    /** 跟踪详情 */
    handleTrackDetails(row){
      this.open6 = true;
      console.log(row.id);
      this.title = row.name + "跟踪详情";
      getStudenttrackstuSn(row.id).then(res => {
        this.trackDetails = res.data;
        console.log(this.trackDetails);
      })
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getStudent(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改学生";
      });
    },
    /** 修改单个状态*/
    updateSingleStatus(row) {
      updateStudent(row).then(response => {
        this.form = response.data;
        this.getList();
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateStudent(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.open2 = false;
              this.getList();
            });
          } else {
            addStudent(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 修改状态按钮提交 */
    submitForm2(){
      updateStudentState(this.updateForm).then(res => {
        this.$modal.msgSuccess("状态修改成功");
        this.open2 = false;
        this.getList();
      })
    },
    /** 留级转班 */
    submitRepeatForm(){
      repeatGrade(this.repeatGradeForm).then(res => {
        this.$modal.msgSuccess("信息修改成功");
        this.open3 = false;
        this.getList();
      })
    },
    /** 转班 */
    handleRepeat(row){
      this.resetRepeat();
      const id = row.id || this.ids;
     // this.repeatGradeForm.id = id;
      getStudent(id).then(res => {
        this.repeatGradeForm.id = res.data.id;
        this.form.name = res.data.name;
        //this.repeatGradeForm.studentStatus = res.data.studentStatus;
        this.title = this.form.name + "转班处理";
      });
      this.open3 = true;

    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除学生编号为"' + ids + '"的数据项？').then(function() {
        return delStudent(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('student/student/export', {
        ...this.queryParams
      }, `student_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
